#ifndef rtps_ThreadSafeCircularBuffer_H
#define rtps_ThreadSafeCircularBuffer_H

#include "rtps/config.h"
#include "rtps/common/types.h"
#include "rtps/utils/Lock.h"
#include "rtps/utils/Log.h"

#ifdef __cplusplus
extern "C" {
#endif

struct rtps_ThreadSafeCircularBuffer {
    void* m_buffer[THREAD_POOL_WORKLOAD_QUEUE_LENGTH + 1];
    uint16_t m_head;
    uint16_t m_tail;
    sys_mutex_t m_mutex;
    bool m_initialized;
    void (*decallback)(void *);
};

struct rtps_ThreadSafeCircularBuffer *
rtps_ThreadSafeCircularBuffer_init(void (*args)(void *));

void 
rtps_ThreadSafeCircularBuffer_deinit(struct rtps_ThreadSafeCircularBuffer *tscb);

bool
rtps_ThreadSafeCircularBuffe_moveElementIntoBuffer(struct rtps_ThreadSafeCircularBuffer *tscb, void *elem );

bool 
rtps_ThreadSafeCircularBuffer_moveFirstInto( struct rtps_ThreadSafeCircularBuffer *tscb, void **hull);

void 
rtps_ThreadSafeCircularBuffer_clear(struct rtps_ThreadSafeCircularBuffer *tscb);


#ifdef __cplusplus
}
#endif

#endif